package com.gx.mxbbx.service.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.gx.mxbbx.dao.MxbPolicyMapper;
import com.gx.mxbbx.po.MxbPolicy;
import com.gx.mxbbx.service.MxbPolicyService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import javax.transaction.Transactional;
import java.sql.Timestamp;
import java.util.List;

@Service
@Transactional
public class MxbPolicyServiceImpl implements MxbPolicyService {
    @Autowired
    private MxbPolicyMapper mxbPolicyMapper;

    public PageInfo<MxbPolicy> getpolicyList(String policyYear, Integer currentPage, Integer limit) {
        PageHelper.startPage(currentPage, limit);
        List<MxbPolicy> list = mxbPolicyMapper.getpolicyList(policyYear);
        PageInfo<MxbPolicy> pageInfo = new PageInfo<MxbPolicy>(list);
        return pageInfo;
    }

    public void mxbpolicyadd(MxbPolicy mxbPolicy) {
        mxbPolicy.setCreateTime(new Timestamp(System.currentTimeMillis()));
        mxbPolicy.setUpdateTime(new Timestamp(System.currentTimeMillis()));
        mxbPolicyMapper.mxbpolicyadd(mxbPolicy);
    }

    public void mxbpolicydelete(Integer id) {
        mxbPolicyMapper.mxbpolicydelete(id);
    }

    public MxbPolicy openmxbpolicyEdit(Integer id) {
        MxbPolicy mxbPolicy = mxbPolicyMapper.openmxbpolicyEdit(id);
        return mxbPolicy;
    }

    public void mxbpolicyedit(MxbPolicy mxbPolicy) {
        mxbPolicy.setUpdateTime(new Timestamp(System.currentTimeMillis()));
        mxbPolicyMapper.mxbpolicyedit(mxbPolicy);
    }
}
